package org.example.everyday;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * <p>
 *
 * @author anlu
 * @date 2022/6/11 0011 16:54
 */
public class Lc926 {
    public static void main(String[] args) {
        Lc926 lc926 = new Lc926();
        String s = "00110";
        int res = lc926.minFlipsMonoIncr(s);
        System.out.println(res);

    }
    public int minFlipsMonoIncr(String s) {
        int n = s.length();

        int dp0 = 0, dp1 = 0;
        for (int i = 0; i < n; i++) {
            char c = s.charAt(i);
            int dp0New = dp0, dp1New = Math.min(dp0,dp1);
            if(c == '1'){
                dp0New++;
            } else {
                dp1New++;
            }
            dp0 = dp0New;
            dp1 = dp1New;
        }
        return Math.min(dp0,dp1);
    }




}
